package com.example.connecting_dots_android;

import android.app.Activity;
import android.content.Context;
import android.content.SharedPreferences;
import android.util.DisplayMetrics;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.view.ViewGroup.MarginLayoutParams;
import android.widget.GridLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;

public class Utils {

	/**
	 * method to get isMute from shared preferences
	 * @param context
	 * @return
	 */
	public static boolean getIsMute(Context context) {
		SharedPreferences mySharedPreferences = context.getSharedPreferences("mute",
				Activity.MODE_PRIVATE);
		return mySharedPreferences.getBoolean("isMute", false);
	}


	/**
	 *  method to set the background image
	 * @param context
	 * @param view
	 */
	
	public static void setBackgroundImage(Context context,View view) {
		SharedPreferences mySharedPreferences = context.getSharedPreferences(
				"background", Activity.MODE_PRIVATE);
		int backgroundImageId = getBackgroundImageId(mySharedPreferences.getInt(
						"myBackgroundImage", 0));
		view.setBackgroundResource(backgroundImageId);

	}
	
	/**
	 * method to get an id for a background image
	 * @param imageId
	 * @return
	 */
		private static int getBackgroundImageId(int imageId){
		
			if(imageId<Constants.backgroundsIds.length)
				return Constants.backgroundsIds[imageId];
			else
				return Constants.backgroundsIds[0];
		}
		
}
